import request from '../request/index'

//定义登录请求方法
export function login(data){
    return request({
        url: '/UserApi/user/login',
        method: 'post',
        data: data  //省略结构data: data
    })
}
//定义注册请求方法
export function register(data){
    return request({
        url: '/UserApi/user/register',
        method: 'post',
        data: data  //省略结构data: data
    })
}
//定义更新密码的请求方法
export function forgotPassword(data){
    return request({
        url: '/UserApi/user/forgotPassword',
        method: 'post',
        data: data  //省略结构data: data
    })
}
//定义查找重复用户名的方法
export function onRepeatUserName(data){
    return request({
        url: '/UserApi/user/onRepeatUserName',
        method: 'get',
        params: data  //省略结构data: data
    })
}
//定义查找重复电话号码的方法
export function onRepeatPhone(data){
    return request({
        url: '/UserApi/user/onRepeatPhone',
        method: 'get',
        params: data  //省略结构data: data
    })
}
//定义查找验证码的方法
export function phone(data){
    return request({
        url: '/UserApi/user/phone',
        method: 'get',
        params: {phone:data}  //省略结构data: data
    })
}

export function phonelogin(data){
    return request({
        url: '/UserApi/user/phonelogin',
        method: 'post',
        data: data  //省略结构data: data
    })
}

export function findAllUsers(id){
    return request({
        url:"/UserApi/user/GeRenXinXi",
        method:"post",
        params:{
            id:id
        }
    })
}

//修改个人信息
export function UserUpdate(id,username,phone){
    return request({
        url:"/UserApi/user/UpdateUser",
        method:"post",
        params:{
            id:id,
            username:username,
            phone:phone
        }
    })
}

//修改密码

export function passwordsUpdate(id,oldPwd,newPwd,newPwd1){
    return request({
        url:"/UserApi/user/PasswordUpdate",
        method:"post",
        params:{
            id:id,
            oldPwd:oldPwd,
            newPwd:newPwd,
            newPwd1:newPwd1
        }
    })
}

// 上传头像
export function uploadAvatar(file) {
  const formData = new FormData()
  formData.append('file', file)
  return request({
    url: '/DeliveryApi/delivery/upload',
    method: 'post',
    data: formData,
    headers: { 'Content-Type': 'multipart/form-data' }
  })
}